package com.project.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.AreaBean;
import com.project.service.AreaService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("area")
public class AreaController {

    @Resource
    private AreaService areaService;

    //显示所有信息
    @RequestMapping("findAllArea")
    @ResponseBody
    public IPage<AreaBean> findAllArea(@RequestParam(value = "pageNo", defaultValue = "1") int pageNo,
                                       @RequestParam(value = "pageSize", defaultValue = "3") int pageSize) {
        return areaService.findAllArea(pageNo, pageSize);
    }

    //添加区域
    @RequestMapping("addArea")
    @ResponseBody
    public String addArea(AreaBean areaBean) {
        areaService.addArea(areaBean);
        return "ok";
    }


    //模糊查询
    @RequestMapping("findName")
    @ResponseBody
    public IPage<AreaBean> findName(@RequestParam(value = "pageNo", defaultValue = "1") int pageNO,
                                    @RequestParam(value = "pageSize", defaultValue = "3") int pageSize,
                                    String areaName, String areaSeed, String className) {
        return areaService.findName(pageNO, pageSize, areaName, areaSeed, className);
    }

    @RequestMapping("findAllList")
    @ResponseBody
    public List<AreaBean> findAllList(){
        return areaService.findAllList();
    }



    @RequestMapping("findAllList2")
    @ResponseBody
    public List<AreaBean> findAllList2(){
        return areaService.findAllList2();
    }


}
